import { getDepartmentOptions } from '@/api/department'
import { ref } from 'vue'

/**
 * 获取部门下拉选项
 */
export const useGetDepartmentOptions = () => {
  const getOptionsLoading = ref(false)
  const options = ref<Array<DepartmentOption>>([])

  const getOptions = async () => {
    getOptionsLoading.value = true
    const res = await getDepartmentOptions()
    getOptionsLoading.value = false
    if (res.data.code === 20000) {
      options.value = res.data.data
      return ''
    }
    return res.data.message
  }

  return {
    options,
    getOptionsLoading,
    getOptions,
  }
}
